package com.wibo.account;

import java.util.ArrayList;
import java.util.List;

import weibo4android.Count;
import weibo4android.IDs;
import weibo4android.Paging;
import weibo4android.Status;
import weibo4android.User;
import weibo4android.Weibo;
import weibo4android.WeiboException;

import com.wibo.common.Constants;
import com.wibo.common.FileDbHelper;
import com.wibo.common.UserItem;
import com.wibo.common.Utility;
import com.wibo.common.WeiboItem;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.Process;
import android.text.Html;
import android.text.TextPaint;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

public class WiboUserDetailsActivity extends Activity implements OnClickListener, OnTouchListener {

	private boolean mbRunning = false;
	
	public static final String TAG = "WiboUserDetailsActivity";

	private static Weibo mWeibo = null;
	private static OAuthConstant mAuthConstant = null;
	//private User mUser = null;
	private UserItem mUserItem = null;
	private long mUserId = -1;
	private boolean mIsMe = true;
	
	CUserManager mUserManager = null;
	protected FileDbHelper mDbHelper = null;
	
	private RelativeLayout mUserHeadLayout;
	private ScrollView mMainScroll;
	
	private ImageView mHeadImage;
	private ImageView mBackBtnView;
	private ImageView mBackHomeBtnView;
	private ImageView mSexImage;
	private RelativeLayout mAddFocusLayout;
	private TextView mOpeateText;
	
	private TextView mUserName;
	private TextView mAdressText;
	private TextView mLoginName;
	private TextView mSignText;
	private TextView mFocusText;
	private TextView mFansText;
	private TextView mWeiboCountText;
	private TextView mTopicText;
	private TextView mCollectText;
	private TextView mBlackListText;
	
	private String mBigHeadPicUrl = "";
	
	private LinearLayout mFocusLayout;
	private LinearLayout mFansLayout;
	private RelativeLayout mMoreWeiboLayout;
	private ProgressBar mMoreWeiboProgress;
	
	private ArrayList<WeiboItem> mItemDataList;
	private EmotionsParser mParser;
	
	private static final int GET_USER_FINISH = 0;
	private static final int GET_USER_FROM_DB_FINISH = 6;
	private static final int GET_USER_ERROR = 1;
	private static final int GET_USER_IMAGE_FINISH = 2;
	private static final int GET_WEIBO_FINISH = 3;
	private static final int GET_WEIBO_ERROR = 4;
	private static final int REFRESH_LIST = 5;
	private static final int CREATE_FRIEND_FINISHED = 7;
	private static final int CREATE_FRIEND_ERROR = 8;
	private static final int DESTROY_FRIEND_FINISHED = 9;
	private static final int DESTROY_FRIEND_ERROR = 10;
	

	private Handler mHandler = new Handler() {
		
		@Override
		public void handleMessage(Message msg) {
			if(!mbRunning){

				Log.e(TAG, "stop by not running flag!");
	    		return;
	    	}
			switch (msg.what) {
			case GET_USER_FINISH:
				if (msg.obj != null){
					User user = (User)msg.obj;
					if (mIsMe) {
						mUserManager.setAccountUser(user);
						mUserManager.setUserId(user.getId());
					}
					
					mFocusLayout.setEnabled(true);
					mFansLayout.setEnabled(true);
					mMoreWeiboLayout.setEnabled(true);
					mAddFocusLayout.setEnabled(true);
					
					mUserManager.insertUserToDB(mDbHelper, user, mIsMe ? Utility.USER_MYSELF : Utility.USER_UNKNOW);
					mUserName.setText(user.getName());
					mAdressText.setText(user.getLocation());
					mLoginName.setText(user.getURL() == null ? "" : user.getURL().toString());
					mSignText.setText(user.getDescription());
					mFocusText.setText(String.valueOf(user.getFriendsCount()));
					mFansText.setText(String.valueOf(user.getFollowersCount()));
					mWeiboCountText.setText(String.valueOf(user.getStatusesCount()));
					mSexImage.setVisibility(ImageView.VISIBLE);
					int id = R.drawable.man_logo_s;
					if (user.getGender().equalsIgnoreCase("f")){
						id = R.drawable.woman_logo_s;
					}else if (user.getGender().equalsIgnoreCase("n")) {
						mSexImage.setVisibility(ImageView.GONE);
					}
					mSexImage.setBackgroundResource(id);
					mBigHeadPicUrl = user.getProfileImageURL().toString();
					mBigHeadPicUrl = mBigHeadPicUrl.replace("/50/", "/180/");
					mHeadImage.setImageBitmap(Utility.getBitmap(WiboUserDetailsActivity.this, mBigHeadPicUrl, Utility.WEIBO_PIC, Utility.LARGE_USER_PIC));
					//mTopicText.setText(String.valueOf(user.));
					//mFansText.setText(String.valueOf(user.getFollowersCount()));
					
					mUserItem = new UserItem();
					mUserItem.setmUserId(user.getId());
					mUserItem.setmUserName(user.getName());
					mUserItem.setmWeiboUserPic(user.getProfileImageURL().toString());
					mUserItem.setmLocation(user.getLocation());
					mUserItem.setmScreenName(user.getScreenName());
					mUserItem.setmDescription(user.getDescription());
					mUserItem.setmFriendsCount(user.getFriendsCount());
					mUserItem.setmFollowersCount(user.getFollowersCount());
					mUserItem.setmStatusesCount(user.getStatusesCount());
					mUserItem.setmCreateTime(Utility.formatDate(user.getCreatedAt()));
					mUserItem.setmVLogo(user.isVerified());
					mUserItem.setmUrl(user.getURL() == null ? "" : user.getURL().toString());
					mUserItem.setmDomain(user.getUserDomain());
					mUserItem.setmSex(user.getGender());
					IDs ids = mUserManager.getMyFocusIds();
					if (!mIsMe) {
						mAddFocusLayout.setVisibility(View.VISIBLE);
						for (int i = 0; i < ids.getIDs().length; i++) {
							if (user.getId() == ids.getIDs()[i]) {
								mUserItem.setmIsFocus(true);
								break;
							}
						}
					}
					
					if (mUserItem.ismIsFocus()) {
						mAddFocusLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.upload_progress_bar_orange));
						mOpeateText.setText(getString(R.string.deletefocus));
					}else{
						mAddFocusLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.upload_progress_bar));
						mOpeateText.setText(getString(R.string.addfocus));
					}
																
					if (!Utility.isImageExist(WiboUserDetailsActivity.this, mBigHeadPicUrl, Utility.WEIBO_PIC, Utility.LARGE_USER_PIC)) {
						getUserPic();
					}
				}
				
				break;
			case GET_USER_ERROR:
				break;
			case GET_USER_FROM_DB_FINISH:
				if (msg.obj != null){
					mFocusLayout.setEnabled(true);
					mFansLayout.setEnabled(true);
					mMoreWeiboLayout.setEnabled(true);
					mAddFocusLayout.setEnabled(true);
					
					mUserItem = (UserItem) msg.obj;
					mUserName.setText(mUserItem.getmUserName());
					mAdressText.setText(mUserItem.getmLocation());
					mLoginName.setText(mUserItem.getmUrl() == null ? "" : mUserItem.getmUrl());
					mSignText.setText(mUserItem.getmDescription());
					mFocusText.setText(String.valueOf(mUserItem.getmFriendsCount()));
					mFansText.setText(String.valueOf(mUserItem.getmFollowersCount()));
					mWeiboCountText.setText(String.valueOf(mUserItem.getmStatusesCount()));
					mSexImage.setVisibility(ImageView.VISIBLE);
					int id = R.drawable.man_logo_s;
					if (mUserItem.getmSex().equalsIgnoreCase("f")){
						id = R.drawable.woman_logo_s;
					}else if (mUserItem.getmSex().equalsIgnoreCase("n")) {
						mSexImage.setVisibility(ImageView.GONE);
					}
					mSexImage.setBackgroundResource(id);
					
					mBigHeadPicUrl = mUserItem.getmWeiboUserPic();
					mBigHeadPicUrl = mBigHeadPicUrl.replace("/50/", "/180/");
					mHeadImage.setImageBitmap(Utility.getBitmap(WiboUserDetailsActivity.this, mBigHeadPicUrl, Utility.WEIBO_PIC, Utility.LARGE_USER_PIC));
					//mTopicText.setText(String.valueOf(user.));
					//mFansText.setText(String.valueOf(user.getFollowersCount()));
					
					//
					if (Utility.isNetworkAvailable(WiboUserDetailsActivity.this) && !Utility.isImageExist(WiboUserDetailsActivity.this, mBigHeadPicUrl, Utility.WEIBO_PIC, Utility.LARGE_USER_PIC)) {
						getUserPic();
					}
				}
				break;
			case GET_USER_IMAGE_FINISH:
				mHeadImage.setImageBitmap(Utility.getBitmap(WiboUserDetailsActivity.this, mUserItem.getmWeiboUserPic(), Utility.WEIBO_PIC, Utility.LARGE_USER_PIC));
				break;
			case GET_WEIBO_FINISH:
				showWeibo();
				break;
			case GET_WEIBO_ERROR:
				break;
			case REFRESH_LIST:
				refreshListPic(msg.arg1);
				break;
			case CREATE_FRIEND_FINISHED:
				if (msg.obj != null) {
					User user = (User)msg.obj;
					mAddFocusLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.upload_progress_bar_orange));
					mOpeateText.setText(getString(R.string.deletefocus));
					mUserManager.getMyFocusIds().addId(user.getId());
				}
				
				break;
			case CREATE_FRIEND_ERROR:
				Toast.makeText(WiboUserDetailsActivity.this, getString(R.string.addfocusFailed), Toast.LENGTH_SHORT).show();
				break;
			case DESTROY_FRIEND_FINISHED:
				if (msg.obj != null) {
					User user = (User)msg.obj;
					mAddFocusLayout.setBackgroundDrawable(getResources().getDrawable(R.drawable.upload_progress_bar));
					mOpeateText.setText(getString(R.string.addfocus));
					mUserManager.getMyFocusIds().deleteId(user.getId());
				}
				break;
			case DESTROY_FRIEND_ERROR:
				Toast.makeText(WiboUserDetailsActivity.this, getString(R.string.destroyfocusFailed), Toast.LENGTH_SHORT).show();
				break;
			}
		}
	};
	
	private void sendMessage(int what, Object obj) {
		Message msg = mHandler.obtainMessage(what, obj);
		mHandler.sendMessage(msg);
	}
	
	private void sendMessage(int what, int arg1, int arg2, Object obj) {
		Message msg = mHandler.obtainMessage(what, arg1, arg2, obj);
		mHandler.sendMessage(msg);
	}
	
	private void setContentViewSkin() {
		int skin = mUserManager.getMySkin();
		switch (skin) {
		case 0:
			setContentView(R.layout.wibouserdetail);
			break;
		case 1:
			setContentView(R.layout.wibouserdetail_2);
			break;
		default:
			setContentView(R.layout.wibouserdetail);
			break;
		}
	}
	
	/* (non-Javadoc)
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		
		mbRunning = true;
		mUserManager = CUserManager.getInstance(this);
		setContentViewSkin();

		

		if (mAuthConstant == null)
			mAuthConstant = OAuthConstant.getInstance();

		if (mWeibo == null)
			mWeibo = mAuthConstant.getWeibo();
		
		if (mDbHelper == null)
			mDbHelper = new FileDbHelper(this);
		
		mUserHeadLayout = (RelativeLayout) findViewById(R.id.userDetailHeadLayout);
		
		mBackBtnView = (ImageView) findViewById(R.id.BackImageBtn);
		mBackBtnView.setOnClickListener(this);
		mBackHomeBtnView = (ImageView) findViewById(R.id.BackHomeImageBtn);
		mBackHomeBtnView.setOnClickListener(this);
		
		mMainScroll = (ScrollView) findViewById(R.id.userScrollView);
		mMainScroll.setOnTouchListener(this);
		//mMainScroll.setOnScrollListener(this);
		
		mHeadImage = (ImageView) findViewById(R.id.HeadImage);
		mSexImage = (ImageView) findViewById(R.id.SexImage);
		mSexImage.setVisibility(ImageView.GONE);
		mAddFocusLayout = (RelativeLayout) findViewById(R.id.userOperate);
    	mOpeateText = (TextView) findViewById(R.id.operateText);
    	mAddFocusLayout.setOnClickListener(this);
    	mAddFocusLayout.setEnabled(false);
		
		mUserName = (TextView) findViewById(R.id.UserNameText);
		TextPaint tp = mUserName.getPaint(); 
    	tp.setFakeBoldText(true);
		mUserName.setFocusable(true);
		mUserName.setFocusableInTouchMode(true);
		mUserName.requestFocus();
		mAdressText = (TextView) findViewById(R.id.AdressText);
		mLoginName = (TextView) findViewById(R.id.loginNameText);
		mSignText = (TextView) findViewById(R.id.SignText);
		mFocusText = (TextView) findViewById(R.id.focusText);
		mFansText = (TextView) findViewById(R.id.fansText);
		mWeiboCountText = (TextView) findViewById(R.id.weiboCountText);
		mTopicText = (TextView) findViewById(R.id.topicText);
		
		mFocusLayout = (LinearLayout) findViewById(R.id.focusLayout);
		mFocusLayout.setOnClickListener(this);
		mFansLayout = (LinearLayout) findViewById(R.id.fansLayout);
		mFansLayout.setOnClickListener(this);
//		mCollectText = (TextView) findViewById(R.id.EditBtnImage);
//		mBlackListText = (TextView) findViewById(R.id.EditBtnImage);
		
		mMoreWeiboLayout = (RelativeLayout) findViewById(R.id.moreWeiboLayout);
		mMoreWeiboLayout.setOnClickListener(this);
		
		mFocusLayout.setEnabled(false);
		mFansLayout.setEnabled(false);
		mMoreWeiboLayout.setEnabled(false);
		
		mMoreWeiboProgress = (ProgressBar) findViewById(R.id.gettingWeiboPro);
		mMoreWeiboProgress.setVisibility(ProgressBar.GONE);
		
		mItemDataList = new ArrayList<WeiboItem>();
		mParser = new EmotionsParser(this); 
		
		Bundle extras = getIntent().getExtras();
		if (extras != null) {
			mUserId = extras.getLong("userId");
			
			if (mUserId > 0) {
				mIsMe = false;
				mUserHeadLayout.setVisibility(RelativeLayout.VISIBLE);
				UserItem item = (UserItem)extras.get("userItem");
				if (item != null) {
					sendMessage(GET_USER_FROM_DB_FINISH, item);
				}else{
					UserItem userItem = mUserManager.getUserFromDB(mDbHelper, mUserId, Utility.USER_UNKNOW);
					if (userItem != null)
						sendMessage(GET_USER_FROM_DB_FINISH, userItem);
				}
				if (Utility.isNetworkAvailable(this))
					getUser();
			}
		}else{
			IntentFilter intentFilter = new IntentFilter();
			intentFilter.addAction(WiboMainTabActivity.NOTIFICATION_FRESH_FANS);
	      	registerReceiver(mNotificationBroadcast, intentFilter);
	      	
			mIsMe = true;
			if (mUserManager.getAccountUser() == null) {
				UserItem userItem = mUserManager.getUserItem();
				SharedPreferences settings = getSharedPreferences(WiboMainTabActivity.USER_INFO, 0);
				long userId = settings.getLong(WiboMainTabActivity.USER_ID, -1);
				mUserManager.setUserId(userId);
				mUserId = mUserManager.getUserId();
				if (userItem == null){
					userItem = mUserManager.getUserFromDB(mDbHelper, mUserManager.getUserId(), Utility.USER_MYSELF);
					if (userItem != null){
						sendMessage(GET_USER_FROM_DB_FINISH, userItem);
					}else{
						if (Utility.isNetworkAvailable(this))
							getUser();
					}
				}else{
					sendMessage(GET_USER_FROM_DB_FINISH, userItem);
				}
				
				if (Utility.isNetworkAvailable(this))
					getUser();
			}else{
				mUserId = mUserManager.getAccountUser().getId();
				sendMessage(GET_USER_FINISH, mUserManager.getAccountUser());
			}
		}
		
		
	}
	
	private final BroadcastReceiver mNotificationBroadcast = new BroadcastReceiver() {
		public void onReceive(Context context, Intent intent) {
			if(intent.getAction().equals(WiboMainTabActivity.NOTIFICATION_FRESH_FANS)){
				intent = new Intent();
				intent.setAction(WiboMainTabActivity.CLEAN_FANS_ACTION);
				sendBroadcast(intent);
				
				if (!Utility.isNetworkAvailable(WiboUserDetailsActivity.this)){
					Toast.makeText(WiboUserDetailsActivity.this, getString(R.string.networkFail), Toast.LENGTH_SHORT).show();
					return;
				}
				intent = new Intent(WiboUserDetailsActivity.this, UserListActivity.class);
				Bundle bundle = new Bundle();
				bundle.putLong("userId", mUserManager.getUserId());
				bundle.putString("userName", mUserManager.getUserName());
				bundle.putInt("type", 1);
				intent.putExtras(bundle);
				startActivity(intent);
			}
		}
	};
	
	/* (non-Javadoc)
	 * @see android.app.Activity#onResume()
	 */
	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
		Bundle extras = getIntent().getExtras();
		if (extras != null) {
			
		}else{
			if (mIsMe) {
				SharedPreferences lastPreferences = getSharedPreferences(Constants.PREFERENCE_NAME, 2);
	            SharedPreferences.Editor editor = lastPreferences.edit();
	            editor.putInt(Constants.PREFERENCE_RECORD, 2);
	            editor.commit();
	            
//	            if (mUserManager.getAccountUser() == null) {
//					UserItem userItem = mUserManager.getUserItem();
//					
//					if (userItem == null){
//						userItem = mUserManager.getUserFromDB(mDbHelper, mUserManager.getUserId(), Utility.USER_MYSELF);
//						if (userItem != null){
//							sendMessage(GET_USER_FROM_DB_FINISH, userItem);
//						}else{
//							finish();
//						}
//					}else{
//						sendMessage(GET_USER_FROM_DB_FINISH, userItem);
//					}
//					
//					if (Utility.isNetworkAvailable(this))
//						getUser();
//				}else{
//					mUserId = mUserManager.getAccountUser().getId();
//					sendMessage(GET_USER_FINISH, mUserManager.getAccountUser());
//				}
			}
		}
	}



	/* (non-Javadoc)
	 * @see android.app.Activity#onBackPressed()
	 */
	@Override
	public void onBackPressed() {
		// TODO Auto-generated method stub
		super.onBackPressed();
		
		if (!mIsMe) {
			finish();
		}
	}

	/* (non-Javadoc)
	 * @see android.app.Activity#onPause()
	 */
//	@Override
//	protected void onPause() {
//		// TODO Auto-generated method stub
//		super.onPause();
//		if (!mIsMe) {
//			finish();
//		}
//	}



	private Thread mGetUserThread = null;
	private void getUser() {
		if (mGetUserThread != null) {
			if (mGetUserThread.isAlive()) {
				mGetUserThread.interrupt();
			}
			mGetUserThread = null;
		}
		
		mGetUserThread = new Thread(new Runnable() {
			
			@Override
			public void run() {
				try {
					if (mUserManager.getMyFocusIds() == null) {
						IDs ids = mWeibo.getFriendsIDSByUserId(String.valueOf(mUserManager.getUserId()), 0);
						if (ids != null) {
							mUserManager.setMyFocusIds(ids);
						}else{
							//
						}
					}
					User user = null;
					if (mIsMe){
						user = mWeibo.verifyCredentials();
					}else{
						user = mWeibo.showUser(String.valueOf(mUserId));
					}
					
					
					if (user != null) {
						sendMessage(GET_USER_FINISH, user);
					}
					
				} catch (WeiboException e) {
					e.printStackTrace();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
		
		mGetUserThread.start();
	}
	
	/* (non-Javadoc)
	 * @see android.app.Activity#onDestroy()
	 */
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		
		if (mGetUserThread != null) {
			if (mGetUserThread.isAlive()) {
				mGetUserThread.interrupt();
			}
			mGetUserThread = null;
		}
		
		if (mGetUserPicThread != null) {
			if (mGetUserPicThread.isAlive()) {
				mGetUserPicThread.interrupt();
			}
			mGetUserPicThread = null;
		}
		
		if (mGetWeiboThread != null) {
			if (mGetWeiboThread.isAlive()) {
				mGetWeiboThread.interrupt();
			}
			mGetWeiboThread = null;
		}
		
		if (mGetPicThread != null) {
			if (mGetPicThread.isAlive()) {
				mGetPicThread.interrupt();
			}
			mGetPicThread = null;
		}
	}

	private Thread mGetUserPicThread = null;
	private void getUserPic() {
		if (mGetUserPicThread != null) {
			if (mGetUserPicThread.isAlive()) {
				mGetUserPicThread.interrupt();
			}
			mGetUserPicThread = null;
		}
		
		mGetUserPicThread = new Thread(new Runnable() {
			
			@Override
			public void run() {
				if (mUserItem == null) {
					return;
				}
				
				if (mBigHeadPicUrl == null || mBigHeadPicUrl.isEmpty()){
					mBigHeadPicUrl = mUserItem.getmWeiboUserPic();
					mBigHeadPicUrl = mBigHeadPicUrl.replace("/50/", "/180/");
				}
				
				String path = Utility.getImagePath(WiboUserDetailsActivity.this, mBigHeadPicUrl, Utility.WEIBO_PIC, Utility.LARGE_USER_PIC);
				if (path != null) {
					sendMessage(GET_USER_IMAGE_FINISH, null);
				}
			}
		});
		
		mGetUserPicThread.start();
	}
	
	private Thread mGetWeiboThread = null;
	private void getWeibo(final String userId, final long weiboId) {
		if (mGetWeiboThread != null) {
			if (mGetWeiboThread.isAlive()) {
				mGetWeiboThread.interrupt();
			}
			mGetWeiboThread = null;
		}
		
		mGetWeiboThread = new Thread(new Runnable() {
			
			@Override
			public void run() {
				try {
					if (mUserManager.getAccountUser() == null) {
						User user = mWeibo.verifyCredentials();
						if (user != null) {
							mUserManager.setAccountUser(user);
							mUserManager.insertUserToDB(mDbHelper, user, Utility.USER_MYSELF);
							mUserManager.setUserId(user.getId());
						}else{
							sendMessage(GET_WEIBO_ERROR, null);
							return;
						}
					}
					
					if (mItemDataList == null) {
						mItemDataList = new ArrayList<WeiboItem>();
					}
					List<Status> statuses = null;
					if (weiboId <= 0){
						statuses = mWeibo.getUserTimeline(userId);
					}else{
						Paging paging = new Paging(1, 20);
						paging.setMaxId(weiboId - 1);
						statuses = mWeibo.getUserTimeline(userId, paging);
					}
					
					
					if (statuses != null && statuses.size() > 0) {
						ArrayList<WeiboItem> itemDataList = new ArrayList<WeiboItem>();
						
						for (Status status : statuses) {
							WeiboItem itemData = new WeiboItem();
							itemData.setmUserName(status.getUser()
									.getName());
							itemData.setmSentTime(Utility.formatDate(status
									.getCreatedAt()));
							itemData.setmWeiboText(status.getText());
							itemData.setmClientName(status.getSource());

							itemData.setmWeiboUserPic(status.getUser()
									.getProfileImageURL().toString());
							if (status.getThumbnail_pic() != null && !status.getThumbnail_pic().isEmpty()){
								itemData.setmWeiboPic(status.getThumbnail_pic());
								itemData.setmWeiboMidPic(status.getBmiddle_pic());
								itemData.setmWeiboLargePic(status.getOriginal_pic());
							}

							itemData.setmUserId(status.getUser().getId());
							itemData.setmVLogo(status.getUser().isVerified());
							itemData.setmLatitude(String.valueOf(status.getLatitude()));
							itemData.setmLongitude(String.valueOf(status.getLongitude()));
							
							Status transmitStatus = status.getRetweeted_status();
							if (transmitStatus != null) {
								itemData.setmRtrootText(transmitStatus.getText());
								itemData.setmRtrootWeiboPic(transmitStatus.getThumbnail_pic());
								itemData.setmRtrootWeiboMidPic(transmitStatus.getBmiddle_pic());
								itemData.setmRtrootWeiboLargePic(transmitStatus.getOriginal_pic());
								itemData.setmRtrootWeiboId(transmitStatus.getId());
								if (transmitStatus.getUser() != null) {
									itemData.setmRtrootUsername(transmitStatus.getUser().getName());
									itemData.setmRtrootUserId(transmitStatus.getUser().getId());
									itemData.setmRtrootVLogo(transmitStatus.getUser().isVerified());
								}else{
									itemData.setmRtrootUsername("");
									itemData.setmRtrootUserId(-1);
									itemData.setmRtrootVLogo(false);
								}
							}
							itemData.setmWeiboId(status.getId());
							itemDataList.add(itemData);
						}
						
						if (itemDataList.size() > 0) {
							mItemDataList.addAll(itemDataList);
						}
						
						// 获取评论和转发数
						int leftSize = mItemDataList.size();
						List<Count> counts = null;
						int i = 0;
						int j = 0;
						int startIndex = 0;
						String ids = "";
						if (leftSize > WiboMainActivity.GET_COUNT_MAX) {
							do {
								for (; i < startIndex + WiboMainActivity.GET_COUNT_MAX; i++) {
									ids += String.valueOf(mItemDataList.get(i).getmWeiboId()) + ",";
								}
								ids = ids.substring(0, ids.length() - 1);

								counts = mWeibo.getCounts(ids);
								
								if (counts != null) {
									for (Count count : counts) {
										for (j = 0; j < mItemDataList.size(); j++) {
											if (mItemDataList.get(j).getmWeiboId() == count.getId()){
												mItemDataList.get(j).setmCommentCount(String.valueOf(count.getComments()));
												mItemDataList.get(j).setmTransmitCount(String.valueOf(count.getRt()));
												break;
											}
										}
									}
								}
								startIndex += WiboMainActivity.GET_COUNT_MAX;
							} while ((leftSize -= WiboMainActivity.GET_COUNT_MAX) > WiboMainActivity.GET_COUNT_MAX);
						}
						
						if (leftSize > 0 && leftSize <= WiboMainActivity.GET_COUNT_MAX) {
							ids = "";
							for (; i < mItemDataList.size(); i++) {
								ids += String.valueOf(mItemDataList.get(i).getmWeiboId()) + ",";
							}
							ids = ids.substring(0, ids.length() - 1);

							counts = mWeibo.getCounts(ids);
							
							if (counts != null) {
								for (Count count : counts) {									
									for (j = 0; j < mItemDataList.size(); j++) {
										if (mItemDataList.get(j).getmWeiboId() == count.getId()){
											mItemDataList.get(j).setmCommentCount(String.valueOf(count.getComments()));
											mItemDataList.get(j).setmTransmitCount(String.valueOf(count.getRt()));
											break;
										}
									}
								}
							}
						}
						
						if (itemDataList.size() > 0) {
							sendMessage(GET_WEIBO_FINISH, String.valueOf(itemDataList.size()));
						}else{
							sendMessage(GET_WEIBO_FINISH, null);
						}
//						sendMessage(REFRESH_LIST, null);
					}
				} catch (WeiboException e) {
					sendMessage(GET_WEIBO_ERROR, e.getMessage());
					e.printStackTrace();
				}
			}
		});
		
		mGetWeiboThread.start();
	}
	
	private int getItemSkin() {
		int skin = mUserManager.getMySkin();
		switch (skin) {
		case 0:
			return R.layout.weibolistitem;
		case 1:
			return R.layout.weibolistitem_2;
		default:
			return R.layout.weibolistitem;
		}
	}
	
	private int mLastIndex = 0;
	private void showWeibo(){
		LinearLayout weiboLayout = (LinearLayout) findViewById(R.id.WeiboLayout);
		weiboLayout.setVisibility(LinearLayout.VISIBLE);

		final LayoutInflater li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
		LinearLayout layout;
		
		int start = mLastIndex;
		int size = mItemDataList.size();
		for (int i = mLastIndex; i < size; i++){

			layout = new LinearLayout(WiboUserDetailsActivity.this);
			layout = (LinearLayout) li.inflate(getItemSkin(), null);
			final int index = i;
			layout.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
					if (!Utility.isNetworkAvailable(WiboUserDetailsActivity.this)){
						Toast.makeText(WiboUserDetailsActivity.this, getString(R.string.networkFail), Toast.LENGTH_SHORT);
						return;
					}
					Intent intent = new Intent(WiboUserDetailsActivity.this, WeiboDetailsActivity.class);
		    		Bundle bundle = new Bundle();
		    		bundle.putLong("weiboId", mItemDataList.get(index).getmWeiboId());
		    		bundle.putSerializable("weiboItem", mItemDataList.get(index));
					intent.putExtras(bundle);
					startActivity(intent);
				}
			});
			
			RelativeLayout mOriginalWeiboLayout = (RelativeLayout) layout.findViewById(R.id.originalRelativeLayout);
	    	
			ImageView mWeiboUserPic = (ImageView)layout.findViewById(R.id.userPic);
	    	mWeiboUserPic.setVisibility(ImageView.GONE);
	    	ImageView mWeiboPic = (ImageView)layout.findViewById(R.id.weiboPic);
	    	mWeiboPic.setVisibility(ImageView.GONE);
	    	ImageView mPicLogo = (ImageView)layout.findViewById(R.id.picLogo);
	    	mPicLogo.setVisibility(ImageView.GONE);
	    	ImageView mCommentLogo = (ImageView)layout.findViewById(R.id.commentLogo);
	    	mCommentLogo.setVisibility(ImageView.GONE);
	    	ImageView mTransmitLogo = (ImageView)layout.findViewById(R.id.transmitLogo);
	    	mTransmitLogo.setVisibility(ImageView.GONE);
	    	ImageView mVLogo = (ImageView)layout.findViewById(R.id.vLogo);
	    	mVLogo.setVisibility(ImageView.GONE);
	    	ImageView mOriginalWeiboPic = (ImageView)layout.findViewById(R.id.originalWeiboPic);
	    	mOriginalWeiboPic.setVisibility(ImageView.GONE);

	    	TextView userName = (TextView)layout.findViewById(R.id.userName);
	    	TextPaint tp = userName.getPaint(); 
	    	tp.setFakeBoldText(true);
	    	TextView mWeiboText = (TextView)layout.findViewById(R.id.weiboText);
	    	TextView mOriginalText = (TextView)layout.findViewById(R.id.originalWeiboText);
	    	mOriginalText.setVisibility(TextView.GONE);
	    	TextView mSentTime = (TextView)layout.findViewById(R.id.sentTime);
	    	TextView mClientName = (TextView)layout.findViewById(R.id.clientNameText);
	    	TextView mCommentCount = (TextView)layout.findViewById(R.id.commentCountText);
	    	mCommentCount.setVisibility(TextView.GONE);
	    	TextView mTransmitCount = (TextView)layout.findViewById(R.id.transmitCountText);
	    	mTransmitCount.setVisibility(TextView.GONE);
	    	ImageView mGpsLogo = (ImageView) layout.findViewById(R.id.gps_logo);
	    	mGpsLogo.setVisibility(ImageView.GONE);
			
			if (mItemDataList.get(i).getmWeiboPic() != null && !mItemDataList.get(i).getmWeiboPic().isEmpty()) {
				mWeiboPic.setImageBitmap(Utility.getBitmap(this, mItemDataList.get(i).getmWeiboPic(), Utility.WEIBO_PIC, Utility.THUMBNAIL_PIC));
				mWeiboPic.setVisibility(ImageView.VISIBLE);				
			}else{
				mWeiboPic.setVisibility(ImageView.GONE);
				mWeiboPic.setImageBitmap(null);
			}
			
			if (mItemDataList.get(i).getmWeiboUserPic() != null) {
				mWeiboUserPic.setImageBitmap(Utility.getBitmap(this, mItemDataList.get(i).getmWeiboUserPic(), Utility.WEIBO_PIC, Utility.USER_PIC));
				mWeiboUserPic.setVisibility(ImageView.VISIBLE);
			
			}else{
				mWeiboUserPic.setVisibility(ImageView.GONE);
				mWeiboUserPic.setImageBitmap(null);
			}			
			
			if (mItemDataList.get(i).getmUserName() != null)
				userName.setText(mParser.replace(mItemDataList.get(i).getmUserName(), 18, 18));
			if (mItemDataList.get(i).getmWeiboText() != null)
				mWeiboText.setText(mParser.replace(mItemDataList.get(i).getmWeiboText(), 18, 18));

			if (mItemDataList.get(i).getmRtrootWeiboId() > 0) {
				if (mItemDataList.get(i).getmRtrootText() != null && !mItemDataList.get(i).getmRtrootText().isEmpty()){
					mOriginalWeiboLayout.setVisibility(RelativeLayout.VISIBLE);
					mOriginalText.setText(mParser.highlight(mParser.replace(mItemDataList.get(i).getmRtrootUsername() + ": " + mItemDataList.get(i).getmRtrootText(), 18, 18),
							0, mItemDataList.get(i).getmRtrootUsername().length(), getResources().getColor(R.color.sky_blue)));
					mOriginalText.setVisibility(TextView.VISIBLE);
					mWeiboPic.setVisibility(ImageView.GONE);
					
					if (mItemDataList.get(i).getmRtrootWeiboPic() != null && !mItemDataList.get(i).getmRtrootWeiboPic().isEmpty()){
						mOriginalWeiboPic.setImageBitmap(Utility.getBitmap(this, mItemDataList.get(i).getmRtrootWeiboPic(), Utility.WEIBO_PIC, Utility.THUMBNAIL_PIC));
						mOriginalWeiboPic.setVisibility(ImageView.VISIBLE);
					}else{
						mOriginalWeiboPic.setVisibility(ImageView.GONE);
						mOriginalWeiboPic.setImageBitmap(null);
					}
				}else{
					mOriginalWeiboLayout.setVisibility(RelativeLayout.GONE);
					mOriginalText.setVisibility(TextView.GONE);
					mOriginalWeiboPic.setVisibility(ImageView.GONE);
					mOriginalWeiboPic.setImageBitmap(null);
				}
			}else{
				mOriginalWeiboLayout.setVisibility(RelativeLayout.GONE);
				mOriginalText.setVisibility(TextView.GONE);
				mOriginalWeiboPic.setVisibility(ImageView.GONE);
				mOriginalWeiboPic.setImageBitmap(null);
			}
			
			if ((mItemDataList.get(i).getmWeiboPic() != null && !mItemDataList.get(i).getmWeiboPic().isEmpty())
					|| (mItemDataList.get(i).getmRtrootWeiboPic() != null && !mItemDataList.get(i).getmRtrootWeiboPic().isEmpty())){
				mPicLogo.setVisibility(ImageView.VISIBLE);
			}else{
				mPicLogo.setVisibility(ImageView.GONE);
			}
			
			
			if (mItemDataList.get(i).getmSentTime() != null)
				mSentTime.setText(mItemDataList.get(i).getmSentTime());
			
			if (mItemDataList.get(i).getmClientName() != null)
				mClientName.setText(Html.fromHtml(mItemDataList.get(i).getmClientName()));
			
			if (mItemDataList.get(i).getmCommentCount() != null && !mItemDataList.get(i).getmCommentCount().equalsIgnoreCase("0")){
				mCommentCount.setText(mItemDataList.get(i).getmCommentCount());
				mCommentCount.setVisibility(TextView.VISIBLE);
				mCommentLogo.setVisibility(ImageView.VISIBLE);			
			}else {
				mCommentCount.setVisibility(TextView.GONE);
				mCommentLogo.setVisibility(ImageView.GONE);	
			}
			
			if (mItemDataList.get(i).getmTransmitCount() != null && !mItemDataList.get(i).getmTransmitCount().equalsIgnoreCase("0")){
				mTransmitCount.setText(mItemDataList.get(i).getmTransmitCount());
				mTransmitCount.setVisibility(TextView.VISIBLE);
				mTransmitLogo.setVisibility(ImageView.VISIBLE);	
			}else{
				mTransmitCount.setVisibility(TextView.GONE);
				mTransmitLogo.setVisibility(ImageView.GONE);	
			}
			
			if (mItemDataList.get(i).getmLatitude() != null && mItemDataList.get(i).getmLongitude() != null 
					&& !mItemDataList.get(i).getmLatitude().equals("-1.0") && !mItemDataList.get(i).getmLongitude().equals("-1.0")) {
				mGpsLogo.setVisibility(ImageView.VISIBLE);
			}else{
				mGpsLogo.setVisibility(ImageView.GONE);
			}
	    	
	    	addChildToComment(weiboLayout, layout);
		}
		
		mLastIndex = size;
		
		mMoreWeiboProgress.setVisibility(ProgressBar.GONE);
		TextView text = (TextView) findViewById(R.id.textShowWeibo);
		text.setText(getResources().getString(R.string.moreWeibo));
		
		loadWeiboPic(start, size - 1);
	}
	
	private void addChildToComment(LinearLayout comment, LinearLayout layout) {
		comment.addView(layout, new LinearLayout.LayoutParams(
				LinearLayout.LayoutParams.FILL_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT));
	}

	
	private Thread mAddFocusThread = null;

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.userOperate:
			if (mIsMe) {
				return;
			}
			if (mAddFocusThread != null) {
				if (mAddFocusThread.isAlive()) {
					return;
				}
			}
			
			mAddFocusThread = new Thread(new Runnable() {
				
				@Override
				public void run() {
					try {
						if (mUserItem.ismIsFocus()) {
							User user = mWeibo.destroyFriendship(String.valueOf(mUserItem.getmUserId()));
							
							if (user != null) {
								mUserItem.setmIsFocus(false);
								sendMessage(DESTROY_FRIEND_FINISHED, 0, 0, user);
							}else{
								sendMessage(DESTROY_FRIEND_ERROR, 0, 0, null);
							}
						}else{
							User user = mWeibo.createFriendship(String.valueOf(mUserItem.getmUserId()));
							
							if (user != null) {
								mUserItem.setmIsFocus(true);
								sendMessage(CREATE_FRIEND_FINISHED, 0, 0, user);
							}else{
								sendMessage(CREATE_FRIEND_ERROR, 0, 0, null);
							}
						}
					}catch (WeiboException e) {
						e.printStackTrace();
						if (mUserItem.ismIsFocus()) {
							sendMessage(DESTROY_FRIEND_ERROR, 0, 0, null);
						}else{
							sendMessage(CREATE_FRIEND_ERROR, 0, 0, null);
						}
					}
					
				}
			});
			
			mAddFocusThread.start();
			break;
		case R.id.moreWeiboLayout:
			mMoreWeiboProgress.setVisibility(ProgressBar.VISIBLE);
			TextView text = (TextView) findViewById(R.id.textShowWeibo);
			text.setText(getResources().getString(R.string.loading));
			if (mItemDataList == null || mItemDataList.size() == 0) {
				getWeibo(String.valueOf(mUserId), -1);
			}else{
				getWeibo(String.valueOf(mUserId), mItemDataList.get(mItemDataList.size() - 1).getmWeiboId());
			}
			break;
			
		case R.id.BackImageBtn:
			finish();
			break;
		case R.id.BackHomeImageBtn:
			Intent intent = new Intent(WiboUserDetailsActivity.this, WiboMainTabActivity.class);
			startActivity(intent);
			finish();
			break;
		case R.id.focusLayout:
			if (!Utility.isNetworkAvailable(WiboUserDetailsActivity.this)){
				Toast.makeText(WiboUserDetailsActivity.this, getString(R.string.networkFail), Toast.LENGTH_SHORT).show();
				return;
			}
			intent = new Intent(WiboUserDetailsActivity.this, UserListActivity.class);
			Bundle bundle = new Bundle();
			bundle.putLong("userId", mUserId);
			bundle.putString("userName", mUserItem.getmUserName());
			bundle.putInt("type", 0);
			intent.putExtras(bundle);
			startActivity(intent);
			break;
		case R.id.fansLayout:
			if (!Utility.isNetworkAvailable(WiboUserDetailsActivity.this)){
				Toast.makeText(WiboUserDetailsActivity.this, getString(R.string.networkFail), Toast.LENGTH_SHORT).show();
				return;
			}
			intent = new Intent(WiboUserDetailsActivity.this, UserListActivity.class);
			bundle = new Bundle();
			bundle.putLong("userId", mUserId);
			bundle.putString("userName", mUserItem.getmUserName());
			bundle.putInt("type", 1);
			intent.putExtras(bundle);
			startActivity(intent);
			break;
		}
	}

	@Override
	public boolean onTouch(View v, MotionEvent event) {

		return false;
	}
	
	private Thread mGetPicThread = null;
	
	private void loadWeiboPic(final int startIndex, final int lastIndex) {
		
		if (mGetPicThread != null) {
			if (mGetPicThread.isAlive()) {
				mGetPicThread.interrupt();
			}
			mGetPicThread = null;
		}
		
		mGetPicThread = new Thread(new Runnable() {
			
			@Override
			public void run() {
				Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
				int size = mItemDataList.size();
				String path = null;
				for (int i = startIndex; lastIndex < size && i <= lastIndex; i++) {
					path = Utility.getImagePath(WiboUserDetailsActivity.this,mItemDataList.get(i).getmWeiboUserPic(), Utility.WEIBO_PIC, Utility.USER_PIC);
					if (path != null) {
						mItemDataList.get(i).setmIsLoadHeadPic(true);
					}
										
					if (mItemDataList.get(i).getmWeiboPic() != null && !mItemDataList.get(i).getmWeiboPic().isEmpty()){
						path = Utility.getImagePath(WiboUserDetailsActivity.this,mItemDataList.get(i).getmWeiboPic(), Utility.WEIBO_PIC, Utility.THUMBNAIL_PIC);
						if (path != null) {
							mItemDataList.get(i).setmIsLoadWeiboPic(true);
						}
					}
					
					if (mItemDataList.get(i).getmRtrootText() != null && !mItemDataList.get(i).getmRtrootText().isEmpty()) {
						if (mItemDataList.get(i).getmRtrootWeiboPic() != null && !mItemDataList.get(i).getmRtrootWeiboPic().isEmpty()){
							path = Utility.getImagePath(WiboUserDetailsActivity.this,mItemDataList.get(i).getmRtrootWeiboPic(), Utility.WEIBO_PIC, Utility.THUMBNAIL_PIC);
							if (path != null) {
								mItemDataList.get(i).setmIsLoadRootPic(true);
							}
						}
					}
					
					sendMessage(REFRESH_LIST, i, 0, null);
				}
			}
		});
		
		mGetPicThread.start();
	}
	
	private void refreshListPic(int index) {
		LinearLayout weiboLayout = (LinearLayout) findViewById(R.id.WeiboLayout);
		LinearLayout layout = (LinearLayout)weiboLayout.getChildAt(index);
		
		RelativeLayout mOriginalWeiboLayout = (RelativeLayout) layout.findViewById(R.id.originalRelativeLayout);
    	
		ImageView mWeiboUserPic = (ImageView)layout.findViewById(R.id.userPic);
    	mWeiboUserPic.setVisibility(ImageView.GONE);
    	ImageView mWeiboPic = (ImageView)layout.findViewById(R.id.weiboPic);
    	mWeiboPic.setVisibility(ImageView.GONE);
    	ImageView mPicLogo = (ImageView)layout.findViewById(R.id.picLogo);
    	mPicLogo.setVisibility(ImageView.GONE);
    	ImageView mCommentLogo = (ImageView)layout.findViewById(R.id.commentLogo);
    	mCommentLogo.setVisibility(ImageView.GONE);
    	ImageView mTransmitLogo = (ImageView)layout.findViewById(R.id.transmitLogo);
    	mTransmitLogo.setVisibility(ImageView.GONE);
    	ImageView mVLogo = (ImageView)layout.findViewById(R.id.vLogo);
    	mVLogo.setVisibility(ImageView.GONE);
    	ImageView mOriginalWeiboPic = (ImageView)layout.findViewById(R.id.originalWeiboPic);
    	mOriginalWeiboPic.setVisibility(ImageView.GONE);

    	TextView mOriginalText = (TextView)layout.findViewById(R.id.originalWeiboText);
    	mOriginalText.setVisibility(TextView.GONE);
    	TextView mSentTime = (TextView)layout.findViewById(R.id.sentTime);
    	TextView mClientName = (TextView)layout.findViewById(R.id.clientNameText);
    	TextView mCommentCount = (TextView)layout.findViewById(R.id.commentCountText);
    	mCommentCount.setVisibility(TextView.GONE);
    	TextView mTransmitCount = (TextView)layout.findViewById(R.id.transmitCountText);
    	mTransmitCount.setVisibility(TextView.GONE);
    	ImageView mGpsLogo = (ImageView) layout.findViewById(R.id.gps_logo);
    	mGpsLogo.setVisibility(ImageView.GONE);
		
		if (mItemDataList.get(index).getmWeiboPic() != null && !mItemDataList.get(index).getmWeiboPic().isEmpty()) {
			mWeiboPic.setImageBitmap(Utility.getBitmap(this, mItemDataList.get(index).getmWeiboPic(), Utility.WEIBO_PIC, Utility.THUMBNAIL_PIC));
			mWeiboPic.setVisibility(ImageView.VISIBLE);				
		}else{
			mWeiboPic.setVisibility(ImageView.GONE);
			mWeiboPic.setImageBitmap(null);
		}
		
		if (mItemDataList.get(index).getmWeiboUserPic() != null && !mItemDataList.get(index).getmWeiboUserPic().isEmpty()) {
			mWeiboUserPic.setImageBitmap(Utility.getBitmap(this, mItemDataList.get(index).getmWeiboUserPic(), Utility.WEIBO_PIC, Utility.USER_PIC));
			mWeiboUserPic.setVisibility(ImageView.VISIBLE);
		
		}else{
			mWeiboUserPic.setVisibility(ImageView.GONE);
			mWeiboUserPic.setImageBitmap(null);
		}	
		
		if ((mItemDataList.get(index).getmWeiboPic() != null && !mItemDataList.get(index).getmWeiboPic().isEmpty())
				|| (mItemDataList.get(index).getmRtrootWeiboPic() != null && !mItemDataList.get(index).getmRtrootWeiboPic().isEmpty())){
			mPicLogo.setVisibility(ImageView.VISIBLE);
		}else{
			mPicLogo.setVisibility(ImageView.GONE);
		}
		

		if (mItemDataList.get(index).getmRtrootWeiboId() > 0) {
			if (mItemDataList.get(index).getmRtrootText() != null && !mItemDataList.get(index).getmRtrootText().isEmpty()){
				mOriginalWeiboLayout.setVisibility(RelativeLayout.VISIBLE);
				mOriginalText.setText(mParser.highlight(mParser.replace(mItemDataList.get(index).getmRtrootUsername() + ": " + mItemDataList.get(index).getmRtrootText(), 18, 18),
						0, mItemDataList.get(index).getmRtrootUsername().length(), getResources().getColor(R.color.sky_blue)));
				mOriginalText.setVisibility(TextView.VISIBLE);
				mWeiboPic.setVisibility(ImageView.GONE);
				
				if (mItemDataList.get(index).getmRtrootWeiboPic() != null && !mItemDataList.get(index).getmRtrootWeiboPic().isEmpty()){
					mOriginalWeiboPic.setImageBitmap(Utility.getBitmap(this, mItemDataList.get(index).getmRtrootWeiboPic(), Utility.WEIBO_PIC, Utility.THUMBNAIL_PIC));
					mOriginalWeiboPic.setVisibility(ImageView.VISIBLE);
				}else{
					mOriginalWeiboPic.setVisibility(ImageView.GONE);
					mOriginalWeiboPic.setImageBitmap(null);
				}
			}else{
				mOriginalWeiboLayout.setVisibility(RelativeLayout.GONE);
				mOriginalText.setVisibility(TextView.GONE);
				mOriginalWeiboPic.setVisibility(ImageView.GONE);
				mOriginalWeiboPic.setImageBitmap(null);
			}
		}else{
			mOriginalWeiboLayout.setVisibility(RelativeLayout.GONE);
			mOriginalText.setVisibility(TextView.GONE);
			mOriginalWeiboPic.setVisibility(ImageView.GONE);
			mOriginalWeiboPic.setImageBitmap(null);
		}
		
		
		
		if (mItemDataList.get(index).getmSentTime() != null)
			mSentTime.setText(mItemDataList.get(index).getmSentTime());
		
		if (mItemDataList.get(index).getmClientName() != null)
			mClientName.setText(Html.fromHtml(mItemDataList.get(index).getmClientName()));
		
		if (mItemDataList.get(index).getmCommentCount() != null && !mItemDataList.get(index).getmCommentCount().equalsIgnoreCase("0")){
			mCommentCount.setText(mItemDataList.get(index).getmCommentCount());
			mCommentCount.setVisibility(TextView.VISIBLE);
			mCommentLogo.setVisibility(ImageView.VISIBLE);			
		}else {
			mCommentCount.setVisibility(TextView.GONE);
			mCommentLogo.setVisibility(ImageView.GONE);	
		}
		
		if (mItemDataList.get(index).getmTransmitCount() != null && !mItemDataList.get(index).getmTransmitCount().equalsIgnoreCase("0")){
			mTransmitCount.setText(mItemDataList.get(index).getmTransmitCount());
			mTransmitCount.setVisibility(TextView.VISIBLE);
			mTransmitLogo.setVisibility(ImageView.VISIBLE);	
		}else{
			mTransmitCount.setVisibility(TextView.GONE);
			mTransmitLogo.setVisibility(ImageView.GONE);	
		}
		
		if (mItemDataList.get(index).getmLatitude() != null && mItemDataList.get(index).getmLongitude() != null 
				&& !mItemDataList.get(index).getmLatitude().equals("-1.0") && !mItemDataList.get(index).getmLongitude().equals("-1.0")) {
			mGpsLogo.setVisibility(ImageView.VISIBLE);
		}else{
			mGpsLogo.setVisibility(ImageView.GONE);
		}
	}
}
